﻿using GPS.MODELS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GPS.DataAccessLayer;
using AutoMapper;
using PagedList;
using GPS.ENTITYS;
using GPS.COMMON;
using System.IO;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Oracle.ManagedDataAccess.Client;
using System.Data;
using Microsoft.AspNet.Identity;
using NPOI.HSSF.UserModel;
using OfficeOpenXml;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Globalization;

namespace GPS.DAL
{
    public static class Check_User
    {
        public static string CheckUser(string getuser, string search)
        {
            string strReturn = "";
            if (getuser == "40")
            {
                if (!string.IsNullOrEmpty(search))
                    strReturn = search.Split(':')[0] == "40" ? null : search.Split(':')[0];
                else
                    strReturn = search == null ? null : search.Split(':')[0];
            }
            else
                strReturn = getuser;
            return strReturn;
        }

        public static void Substring_Autocomplate(string str, ref string MA)
        {
            MA = null;
            if (str != null)
            {
                MA = str.Split(':')[0];
            }
        }

        public static void Substring_KhoaHoc(string strKhoaHoc, ref string MaKhoa, ref string TenKhoa)
        {
            if (strKhoaHoc != null)
            {
                string str = strKhoaHoc.Trim();
                int idx = str.LastIndexOf(':');
                if (idx != -1)
                {
                    MaKhoa = str.Substring(0, idx);
                    TenKhoa = str.Substring(idx + 1);
                }
            }
        }


        public static void Substring_hoten(string strhoten, ref string HoDem, ref string Ten)
        {
            if (strhoten != null)
            {
                string str = strhoten.Trim();
                int idx = str.LastIndexOf(' ');
                if (idx != -1)
                {
                    HoDem = str.Substring(0, idx);
                    Ten = str.Substring(idx + 1);
                }
                else
                {
                    Ten = strhoten;
                }
            }
        }

        //public static string CheckUser(string strFormHoTen, ref strHoDem, ref strTen)
        //{
        //    string 
        //    string strHoDem = null;
        //    string strTen = null;

        //      if (SearchModel.pHV_TEN != null)
        //    {
        //        string str = SearchModel.pHV_TEN.Trim();
        //        int idx = str.LastIndexOf(' ');
        //        if (idx != -1)
        //        {
        //            hodem = str.Substring(0, idx);
        //            ten = str.Substring(idx + 1);
        //        }
        //        else
        //        {
        //            ten = SearchModel.pHV_TEN;
        //        }
        //    }
        //    return strHoDem, strTen;
        //}
    }
}